package common.util.digestUtils.sha;

import org.apache.commons.codec.binary.Hex;
import org.apache.commons.codec.digest.DigestUtils;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class ImoocSHA {

    private static String src = "imooc security sha";

    public static void main(String[] args) {
        jdkSHA1();
        ccSHA1();
    }

    public static void jdkSHA1() {
        try {
            MessageDigest md = MessageDigest.getInstance("SHA");
            md.update(src.getBytes());
            System.out.println("jdk sha-1 : " + Hex.encodeHexString(md.digest()));
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
    }


    public static void ccSHA1() {
        System.out.println("cc sha1 - 1 :" + DigestUtils.sha1Hex(src.getBytes()));
        System.out.println("cc sha1 - 2 :" + DigestUtils.sha1Hex(src));
    }

    //384、256、512。。。。。。

}
